package function.maker;

import function.maker.UnaryFunctionMaker;
import function.binary.BinaryFunction;
import function.unary.UnaryFunction;

/**
 * A class containing common predicates. Some predicates may not be
 * useful in practice, but maybe useful for testing purposes.
 * 
 * Fully Tested: No
 * Fully Documented: No
 * Created: 9-Apr-2012
 * Last Updated: 9-Apr-2012
 * 
 * @author Shimu Wu
 */
public class UnaryPredicateMaker extends UnaryFunctionMaker{

    private UnaryPredicateMaker() {
    }

    /**
     * A UnaryPredicate that always returns true (a tautology)
     * 
     * @param <T>
     * @param class1 
     * @return  
     */
    public static <T> UnaryFunction<T, Boolean> unaryAlwaysTrue(
            Class<T> class1) {
        return new UnaryFunction<T, Boolean>() {

            public Boolean evaluate(T e) {
                return Boolean.TRUE;
            }
        };
    }

    /**
     * A UnaryPredicate that always returns false (a contradiction)
     * @param <T>
     * @param class1 
     * @return  
     */
    public static <T> UnaryFunction<T, Boolean> unaryAlwaysFalse(
            Class<T> class1) {
        return new UnaryFunction<T, Boolean>() {

            public Boolean evaluate(T e) {
                return Boolean.FALSE;
            }
        };
    }

    /**
     * A BinaryPredicate that always returns true (a tautology)
     * 
     * @param <T1>
     * @param <T2>
     * @param class1 
     * @param class2 
     * @return  
     */
    public static <T1, T2> BinaryFunction<T1, T2, Boolean> binaryAlwaysTrue(
            Class<T1> class1, Class<T2> class2) {
        return new BinaryFunction<T1, T2, Boolean>() {

            public Boolean evaluate(T1 e1, T2 e2) {
                return Boolean.TRUE;
            }
        };
    }

    /**
     * A BinaryPredicate that always returns false (a contradiction)
     * 
     * @param <T1>
     * @param <T2>
     * @param class1 
     * @param class2 
     * @return  
     */
    public static <T1, T2> BinaryFunction<T1, T2, Boolean> binaryAlwaysFalse(
             Class<T1> class1, Class<T2> class2) {
        return new BinaryFunction<T1, T2, Boolean>() {

            public Boolean evaluate(T1 e1, T2 e2) {
                return Boolean.FALSE;
            }
        };
    }
}
